//
//  CustomPickerView.m
//  mUBB
//
//  Created by Cosmin Stirbu on 3/8/13.
//  Copyright (c) 2013 Cosmin Stirbu. All rights reserved.
//

#import "CustomPickerView.h"
#import "UIViewAdditions.h"
#import "Constants.h"

@implementation CustomPickerView

@synthesize delegate, toolBar, timePickerView;

- (void)presentPickerViewFromView:(UIView *)view {
    _presentingView = view;
    UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
    _presentingView.userInteractionEnabled = NO;
    [mainWindow addSubview:self];
    self.top = mainWindow.bottom;
    [UIView animateWithDuration:0.3
                     animations:^{
                         self.bottom = mainWindow.bottom;
                     }];
}

- (void)dismissPickerView {
    UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
    _presentingView.userInteractionEnabled = YES;
    [UIView animateWithDuration:0.3
                     animations:^{
                         self.top = mainWindow.bottom;
                     }
                     completion:^(BOOL finished) {
                         [self removeFromSuperview];
                     }
     ];
}


- (IBAction)okPressed:(id)sender {
    [delegate didDismissPickerView];
    [self dismissPickerView];
}


@end
